﻿namespace MEF_Test.Bricks
{
    using System.Configuration;

    public class ModulesSettingsSection : ConfigurationSection
    {

        #region Properties

        /// <summary>
        /// Gets or sets the mappings between contracts and types.
        /// </summary>
        /// <value>The contract to type mappings.</value>
        [ConfigurationCollection(typeof(MappingsCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
        [ConfigurationProperty("ContractToTypeMappings", IsDefaultCollection = false)]
        public MappingsCollection ContractToTypeMappings
        {
            get
            {
                var contractToTypeMappings = (MappingsCollection)this["ContractToTypeMappings"];                
                if (contractToTypeMappings == null)
                {
                    contractToTypeMappings = new MappingsCollection();
                    this["ContractToTypeMappings"] = contractToTypeMappings;
                }

                return contractToTypeMappings;
            }

            set
            {
                this["ContractToTypeMappings"] = value;
            }
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Gets a value indicating whether the <see cref="T:System.Configuration.ConfigurationElement"/> object is read-only.
        /// </summary>
        /// <returns>
        /// true if the <see cref="T:System.Configuration.ConfigurationElement"/> object is read-only; otherwise, false.
        /// </returns>
        public override bool IsReadOnly()
        {
            return false;
        }

        #endregion
    }
}